import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/widget_state.dart';
import 'package:provider/provider.dart';
import 'package:untitled/pages/details.dart';

import 'package:untitled/pages/counter.dart';

class About extends StatelessWidget {
  const About({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('关于'),
      ),
      body: MyAbout(),
    );
  }
}

class MyAbout extends StatefulWidget {
  @override
  _MyAboutState createState() => _MyAboutState();
}

class _MyAboutState extends State<MyAbout> {
  bool _isSelected = true;
  bool? _isChecked = true;
  double progressValue = 10;
  int num = 0;

  static const TextStyle optionsStyle = TextStyle(
    color: Color.fromRGBO(108, 90, 90, 1),
    fontSize: 20.0,
    fontWeight: FontWeight.bold,
    letterSpacing: 8.0,
    decoration: TextDecoration.none,
  );

  @override
  Widget build(BuildContext context) {
    // String title = ModalRoute.of(context)!.settings.arguments as String  'Tabbar过来的';
    String title = 'Tabbar过来的';

    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Text('$title', style: optionsStyle),
        Text(
          '${Provider.of<Counter>(context).count}',
          style: const TextStyle(
              color: Colors.indigoAccent, fontWeight: FontWeight.bold),
        ),
        TextButton(
            child: const Text("TextButton"),
            style: const ButtonStyle(
                backgroundColor: WidgetStatePropertyAll(Colors.amber),
                foregroundColor: WidgetStatePropertyAll(Colors.red)),
            onPressed: () {
              Provider.of<Counter>(context,listen: false).increment();
            }),
        OutlinedButton(
            onPressed: () {
              print("OutLinebutton");
              Navigator.push(
                  context, MaterialPageRoute(builder: (context) => Details()));
            },
            child: Text("OutLinebutton")),
        TextButton(
            onPressed: () {
              print("这是点击的Icon");
            },
            child: const Icon(
              Icons.add_circle,
              color: Color.fromRGBO(213, 123, 24, 1),
              size: 40.0,
            )),
        LinearProgressIndicator(
          backgroundColor: Colors.grey[200],
          valueColor: AlwaysStoppedAnimation(Colors.blue),
          value: .5,
        ),
        LinearProgressIndicator(
          backgroundColor: Colors.grey[200],
          valueColor: AlwaysStoppedAnimation(Colors.blue),
        ),
        CircularProgressIndicator(
          backgroundColor: Colors.grey[200],
          valueColor: AlwaysStoppedAnimation(Colors.blue),
          value: .5,
        ),
        // Switch(
        //     value: _isSelected,
        //     onChanged: (val) {
        //       setState(() {
        //         _isSelected = val;
        //       });
        //     }),
        // Checkbox(
        //     value: _isChecked,
        //     activeColor: Colors.red,
        //     onChanged: (value) {
        //       setState(() {
        //         _isChecked = value;
        //       });
        //     }),
        // Slider(
        //   value: progressValue,
        //   min: 0.0,
        //   max: 100.0,
        //   divisions: 4,
        //   // 只能滑动到 0、25、50、75、100这几个值
        //   onChanged: (double) {
        //     setState(() {
        //       progressValue = double.floorToDouble(); //转成double
        //     });
        //   },
        // ),
        // const Row(
        //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
        //   children: [
        //     Text(
        //       " hello world ",
        //       style: TextStyle(color: Colors.red, fontSize: 12),
        //     ),
        //     Text(
        //       " I am Jack ",
        //       style: TextStyle(color: Colors.amber, fontSize: 14),
        //     ),
        //   ],
        // )
      ],
    );
  }
}
